package com.wang.factory;

import com.wang.enums.Shape;

public class SimpleFactory {
    public static void main(String[] args) {
        ISimple simple = new Simple();
        ISimpleTest iSimpleTest = simple.create(Shape.SQUARE);
        iSimpleTest.print();
        iSimpleTest.noPrint();
    }
}

interface ISimple{
    ISimpleTest create(Shape type);
}

class Simple implements ISimple{

    @Override
    public ISimpleTest create(Shape type) {
        if(type == Shape.CIRCLE){
            return new SimpleTestA();
        }else if(type == Shape.SQUARE){
            return new SimpleTestB();
        }
        return null;
    }
}

abstract class ISimpleTest{
    abstract void print();
    void noPrint(){
        System.out.println(" pppppppp");
    }
}

class SimpleTestA extends ISimpleTest{

    @Override
    public void print() {
        System.out.println(" SimpleTestA");
    }
}
class SimpleTestB extends ISimpleTest{

    @Override
    public void print() {
        System.out.println(" SimpleTestB");
    }
}
